package taller2.view.windows.supervisor;

import java.awt.GridBagLayout;

import taller2.interfaces.Graph;
import taller2.model.factorys.GraphFactory;
import taller2.utils.Constants;
import taller2.utils.Point;
import taller2.view.draws.DrawingArea;
import taller2.view.draws.GraphDrawer;
import taller2.view.menus.supervisor.GraphSupervisorMenu;
import taller2.view.windows.MyWindow;

public class SupervisorWindow {
	protected Graph evaluationGraph;
	protected DrawingArea area;
	protected MyWindow window;
	protected GraphDrawer drawer;
	protected GraphSupervisorMenu selector;
	
	public SupervisorWindow(Graph mainGraph) {
		
		this.window = new MyWindow("ventana");
		this.window.halfScreen();
		this.window.hideOnClose();
		this.window.setResizable(false);
		
		if(mainGraph.isDirected())
			this.evaluationGraph = GraphFactory.directedGraphInstance(mainGraph);
		else
			this.evaluationGraph = GraphFactory.undirectedGraphInstance(mainGraph);

		this.evaluationGraph.normalizeNodesTags();
		
		this.drawer = new GraphDrawer(this.evaluationGraph,Constants.selectedColor,Constants.unSelectedColor);	
		
		this.area = new DrawingArea(Constants.backgroundPath,drawer);
		this.selector = createGraphMenu();
		
		this.window.setLayout(new GridBagLayout());
		this.window.addComponent(this.area, 1, 1, new Point(0, 0));
	
		if(selector != null)
			this.window.addComponent(selector, 1, 0, new Point(0, 1));
	
		this.window.redraw();
	}
		
	protected GraphSupervisorMenu createGraphMenu(){
		return (new GraphSupervisorMenu(this.area,this.evaluationGraph, this));
	}
	
}
